home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / NeoIntroTCL3.0 folder / TCL / NeoDemo / Source / CNeoDemoScrollPane.cp < prev    next >
Encoding:
Text File  |  1993-12-09  |  2.7 KB  |  103 lines  |  [TEXT/KAHL]

  1. /****
  2.  * CNeoDemoScrollPane.c
  3.  *
  4.  *  Copyright © 1992 NeoLogic Systems.  All rights reserved.
  5.  *
  6.  ****/
  7.  
  8. #include "NeoTypes.h"
  9. #include "Constants.h"
  10. #include "CScrollBar.h"
  11. #include "CNeoDemoDoc.h"
  12. #include "CNeoDLOGDialog.h"
  13. #include "CNeoDemoScrollPane.h"
  14.  
  15. /******************************************************************************
  16.  DoHorizScroll
  17.  
  18.         Horizontally scroll the Panorama associated with a ScrollPane
  19.  ******************************************************************************/
  20.  
  21. void    CNeoDemoScrollPane::DoHorizScroll(short    whichPart)
  22. {
  23.     short            delta;            /* percent of total to scroll        */
  24.     short            val;            /* percemt of total at which to set position */
  25.     long            ticks;            /* Tick count at end of Delay        */
  26.     short            nPicts;
  27.     CNeoDemoDoc *    document    = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
  28.  
  29.     nPicts    = document->getImageCount();
  30.     switch (whichPart) {
  31.         case inUpButton:
  32.             delta = -hStep;
  33.             break;
  34.  
  35.         case inDownButton:
  36.             delta = hStep;
  37.             break;
  38.  
  39.         case inPageUp:
  40.             Delay(PAGE_DELAY, &ticks);
  41.             delta = -hStep;            /* page goes 1 pictures at a time */
  42.             break;
  43.  
  44.         case inPageDown:
  45.             Delay(PAGE_DELAY, &ticks);
  46.             delta = hStep;
  47.             break;
  48.     }
  49.  
  50.     val = itsHorizSBar->GetValue();
  51.     val += delta;
  52.  
  53.     if ((nPicts < 2) ||
  54.         (val<0))
  55.         val = 0;
  56.     else
  57.     if (val >= nPicts)
  58.         val = nPicts-1;
  59.  
  60.     DoNDScroll(val+1);
  61.  
  62.     itsHorizSBar->Prepare();
  63. }
  64.  
  65.  
  66. /******************************************************************************
  67.  DoThumbDrag
  68.  
  69.         Adjust associated Panorama when the thumb of a scroll bar is dragged
  70.  ******************************************************************************/
  71.  
  72. void    CNeoDemoScrollPane::DoThumbDrag(short hDelta, short    vDelta)
  73. {
  74.     short            val;
  75.     short            nPicts;
  76.     CNeoDemoDoc *    document    = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
  77.  
  78.     nPicts    = document->getImageCount();
  79.     /* Because of the scaling of control values when using long coordinates    */
  80.     /* dragging the thumb to the beginning or end of the scroll bar will    */
  81.     /* sometimes not fully scroll to the beginning or end. Catch this by    */
  82.     /* checking if the current value is the max or min.                        */
  83.  
  84.     val = itsHorizSBar->GetValue();
  85.     DoNDScroll(val+1);
  86. }
  87.  
  88. /******************************************************************************
  89.  DoScroll
  90.  
  91.     Set correct PICT. All scrolling bottlenecks through this method.
  92.  ******************************************************************************/
  93.  
  94. void CNeoDemoScrollPane::DoNDScroll(short val)
  95. {
  96.     CNeoDemoDoc *    document    = ((CNeoDemoDoc *)((CNeoDLOGDialog *)itsSupervisor)->itsSupervisor);
  97.  
  98.     document->updateImage(nil);            /* save  any edited text info */
  99.  
  100.     document->gotoImage(val, TRUE);        /* setup new image and redraw it immediately */
  101.  
  102. }
  103.